<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.css" rel="stylesheet" />
		<link href="../css/common.css" rel="stylesheet" />
		<style>
			iframe{
				width: 100%;
				height: 100%;
				border: 0;
				padding:0;
				margin: 0;
			}
			/*toast信息提示*/  
			.mui-toast-container {bottom: 50% !important;}  
		</style>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav xq-window-header">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">小冰写诗</h1>
			<a class="mui-btn mui-btn-blue mui-btn-link mui-pull-right" id='pop-action-panel-btn'>操作</a>
		</header>
		<div class="mui-content">
			<iframe id="xiaobing-frame" src="http://poem.msxiaobing.com"></iframe>
		</div>
		<div id="pop-action-panel" class="mui-popover mui-popover-action ">
		    <ul class="mui-table-view">
		        <li class="mui-table-view-cell" id="openURL_inSys">
		            <a>浏览器中打开</a>
		        </li>
		        <li class="mui-table-view-cell" id="about_xiaobingPoem">
		            <a>关于小冰写诗</a>
		        </li>
				<li class="mui-table-view-cell" id="save-card">
				    <a>保存卡片</a>
				</li>
		    </ul>
		    <ul class="mui-table-view">
		        <li class="mui-table-view-cell">
		            <a href="#pop-action-panel"><b>取消</b></a>
		        </li>
		    </ul>
		</div>
		<script src="../js/mui.js"></script>
		<script src="../js/jquery-3.3.1.js"></script>
		<script src="../js/commonUtils.js"></script>
		<script type="text/javascript">
			mui.init();
			mui.ready(function(){
				if (mui.os.plus) {
					return;
				}
				//SettingInfoManager.timeCheckAndSetPageFontFromSetting("msXiaobingPoem");
				SettingInfoManager.setPageFontFromSetting();
				initEleSize();
				initEventListener()
			});
			mui.plusReady(function () {
				//SettingInfoManager.timeCheckAndSetPageFontFromSetting("msXiaobingPoem");
				SettingInfoManager.setPageFontFromSetting();
				initEleSize();
				initEventListener()
			});
			function initEleSize(){
				var winH=$(window).height();
				$('#xiaobing-frame').css('height',(winH-49)+'px');
			}
			function initEventListener(){
				$("#openURL_inSys").on('tap',function(){
					mui("#pop-action-panel").popover('toggle');
					plus.runtime.openURL("http://poem.msxiaobing.com");//调用浏览器打开网址  
				});
				$("#about_xiaobingPoem").on('tap',function(){
					mui("#pop-action-panel").popover('toggle');
					mui.alert("第三方应用--来自微软的 少女诗人小冰 网站");
				});
				$("#save-card").on('tap',function(){
					mui("#pop-action-panel").popover('toggle');
					var obj=document.getElementById("xiaobing-frame").contentWindow;
					var page6=$(obj.document).find(".page6");
					if(!$(page6).is(":visible")){
						mui.alert("没有发现诗文卡片：请按照如下步骤操作\n\r"+
						"1.请先让小冰写完诗歌\n\r2.然后点击[生成诗歌卡片按钮]\n\r3.之后会弹出诗歌卡片\n\r4.接着再来点击保存卡片");
						return;
					}
					//var obj=document.getElementById("xiaobing-frame").contentWindow;
					var ifmObj=obj.document.getElementById("share-card-image");
					var val=$(ifmObj).attr('src');
					if(val){
						var formtData=dateFormat(new Date(),'YYYYmmddHHMMSSsss');;
						var fileName="shiwen-xiaobing-"+formtData;
						commonUtils.baseImgFile(fileName,val,100);
					}else{
						mui.alert("没有找到卡片数据：请重新生成卡片");
					}
				});
				$("#pop-action-panel-btn").on("tap",function(){
					mui("#pop-action-panel").popover('toggle');
				});
			}
		</script>
	</body>
</html>
